/**
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */

var isSymmetric = function (root) {
    if (!root) {
        return true
    }
    return fn(root.left, root.right)
    function fn(root1, root2) {
        if (!root1 && !root2) {
            return true
        }
        if (!root1 || !root2) {
            return false
        }
        return root1.val === root2.val && fn(root1.left, root2.right) && fn(root1.right, root2.left)
    }
};